﻿
@{
    ViewData["Title"] = "绑定电表";
}
<form class="form-horizontal" method="post">
    <div class="form-group">
        <label for="meters" class="col-sm-2 control-label">电表(逗号或换行)</label>
        <div class="col-sm-10">
            <textarea rows="15" name="meters" class=" form-text">@ViewBag.Meters</textarea>
        </div>
    </div>

    <div class="form-group">
        <div class="col-sm-offset-2 col-sm-10">
            <button type="submit" class="btn btn-success">保存</button>
            <button id="btnCallRead" type="button" class="btn btn-warning">读表</button>
        </div>
    </div>
    <div class="form-group">
        <p id="msg" class="lead">@ViewBag.Message</p>
    </div>
</form>
@section Scripts{
    <script type="text/javascript">
        $(function () {
            $("#btnCallRead").click(function () {
                $.ajax({
                    async: true,
                    type: "get",
                    dataType: 'json',
                    xhrFields: { withCredentials: true },
                    url: "/home/callReadMeter",
                    data: {},
                    success: function (box) {
                        $("#msg").text("调用成功");
                    },
                    error: function (XMLHttpRequest, textStatus, errorThrown) {
                        window.location = "/account/index";

                    }
                });

            });

        });
    </script>
}